import { get, post } from '@ugeez/frontend-commons/lib/service';
import { User } from '@shared/types';

export const loginByUsername = async (username: string, password: string/*, captcha:string, captchaSessId:string*/): Promise<string> => {
    // const { token } = await post(`/account/login/username?sessId=${captchaSessId}&captcha=${captcha}`, { username, password });
    const { token } = await post(`/account/login/username`, { username, password });
    return token;
};

export const keepAlive = async (): Promise<User> => {
    const { userId, name, head, roles } = await post(`/account/keepAlive`);
    return {
        id: userId,
        name,
        head,
        isLogined: true,
        roles,
    };
};